package com.fymxy.question_bank_management.service.serviceImpl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fymxy.question_bank_management.mapper.ExamnateMapper;
import com.fymxy.question_bank_management.mapper.StudentExamnateMapper;
import com.fymxy.question_bank_management.pojo.ExamnateKey;
import com.fymxy.question_bank_management.pojo.ExamnateWithBLOBs;
import com.fymxy.question_bank_management.pojo.StudentExamnate;
import com.fymxy.question_bank_management.service.ExamnateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ExamnateServiceImpl implements ExamnateService {

    @Autowired
    private StudentExamnateMapper studentExamnateMapper;

    @Autowired
    private ExamnateMapper examnateMapper;
    @Override
    public int insert(ExamnateWithBLOBs record) {
        return examnateMapper.insert(record);
    }
    @Override
    public int update(ExamnateWithBLOBs record) {
        return examnateMapper.update(record);
    }

    @Override
    public IPage<StudentExamnate> selectAllExamnate(Page page) {
        return studentExamnateMapper.selectAllExamnate(page);
    }

    @Override
    public IPage<StudentExamnate> selectExamnateByStudent(Page page, Integer studentId) {
        return studentExamnateMapper.selectExamnateByStudent(page,studentId);
    }

    @Override
    public IPage<StudentExamnate> selectExamnateByTeacher(Page page, Integer teacherId) {
        return studentExamnateMapper.selectExamnateByTeacher(page,teacherId);
    }

    @Override
    public ExamnateWithBLOBs selectAnswerByStudentNoAndPaperNo(Integer studentNo,Integer paperNo){
        ExamnateKey examnateKey = new ExamnateKey();
        examnateKey.setPaperNo(paperNo);
        examnateKey.setStudentNo(studentNo);
        return examnateMapper.selectByPrimaryKey(examnateKey);
    }
}
